package util;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class PropertyNormalUtils {

	 private static Properties props;  
	    static{  
	        loadProps();  
	    }  
	  
	    synchronized static private void loadProps(){  
	        props = new Properties();  
	        InputStream in = null;  
	        try {  
	            //��һ�֣�ͨ������������л�ȡproperties�ļ���  
	            //in = PropertyUtil.class.getClassLoader().getResourceAsStream("sysConfig.properties");  
	            //�ڶ��֣�ͨ������л�ȡproperties�ļ���  
	            in = PropertyUtils.class.getResourceAsStream("jdbc.properties");
	            props.load(in);  
	        } catch (FileNotFoundException e) {  
	            //logger.error("sysConfig.properties�ļ�δ�ҵ�");  
	        } catch (IOException e) {  
	            //logger.error("����IOException");  
	        } finally {  
	            try {  
	                if(null != in) {  
	                    in.close();  
	                }  
	            } catch (IOException e) {  
	                //logger.error("sysConfig.properties�ļ����رճ����쳣");  
	            }  
	        }  
	        //logger.info("����properties�ļ��������...........");  
	        //logger.info("properties�ļ����ݣ�" + props);  
	    }  
	  
	    public static String getProperty(String key){  
	        if(null == props) {  
	            loadProps();  
	        }  
	        return props.getProperty(key);  
	    }  
	  
	    public static String getProperty(String key, String defaultValue) {  
	        if(null == props) {  
	            loadProps();  
	        }  
	        return props.getProperty(key, defaultValue);  
	    }  
}
